package dynamicJsonVerifyer.verifyers;

import com.alibaba.fastjson.JSONObject;
import dynamicJsonVerifyer.Const;

import java.util.Map;

public abstract class TextFormatVerifyer extends AbsTextVerifyer {

    public JSONObject getVerifyerMatchData() {
        JSONObject json = super.getVerifyerMatchData();
        json.put("formatType", formatType());
        json.put("formatValue", Const.notNull);
        return json;
    }

    abstract String formatType();

    public boolean verifyTextFormat(Map<String, Object> verifyMetadata, Object appointVaildData) {
        String format = (String) verifyMetadata.get("formatValue");
        return verifyTextFomrat(format, (String)appointVaildData);
    }

    abstract boolean verifyTextFomrat(String format, String text);
}
